Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix shell generation panic due to unnecessary 'conflicts_with' #2934

Merged
merged 2 commits into from
Oct 26, 2024

Conversation

zilayo
Copy link

@zilayo zilayo commented Sep 14, 2024

Problem

solana completions -s zsh currently panics when trying to generate zsh completions.

The root cause is the below code which defines a conflicting arg buffer_authority for solana program-v4 show, however buffer_authority is not an argument in program-v4 show:

agave/cli/src/program_v4.rs

Lines 277 to 283 in fc0183d

.arg(
Arg::with_name("all")
.long("all")
.conflicts_with("account")
.conflicts_with("buffer_authority")
.help("Show accounts for all authorities"),
)

This results in clap panicking due to find_any_arg returning None, but the calling macro uses expect()

https://github.com/clap-rs/clap/blob/v2.33.3/src/completions/macros.rs#L15
https://github.com/clap-rs/clap/blob/v2.33.3/src/app/parser.rs#L2168-L2179

Summary of Changes

  • Replaced .conflicts_with("buffer_authority") with .conflicts_with("authority") in program-v4 show
  • Added a unit test that ensures CLI completion works for all supported shells.

Fixes #2929

@mergify mergify bot requested a review from a team September 14, 2024 18:04
@@ -278,7 +278,6 @@ impl ProgramV4SubCommands for App<'_, '_> {
Arg::with_name("all")
.long("all")
.conflicts_with("account")
.conflicts_with("buffer_authority")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgarg66 it's supposed to be .conflicts_with("authority"), right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I push up that change so we can merge this? May as well fix this

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. It should've been the authority. Likely a copy-paste error from program.rs.
Thanks for catching it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the change to this PR.

Copy link

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@pgarg66 pgarg66 merged commit 10bebfa into anza-xyz:master Oct 26, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] solana completion -s zsh panics
4 participants